package org.maggioni.springmvcsandbox.airport.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.maggioni.springmvcsandbox.airport.services.FlightService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class HomeController extends AbstractController {
	
	private FlightService flightService;

	public HomeController() {
		setSupportedMethods(new String[]{METHOD_GET});
		setCacheSeconds(5*60);
	}

	public void setFlightService(FlightService flightService) {
		this.flightService = flightService;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView("home");
		mav.addObject("specials", flightService.getSpecialDeals());
		return mav;
	}
	
	

}
